package com.qiaofang.collectmanage.stub.constants;

import java.util.*;

/**
 * Copyright (C), 2002-2017, 上海巧房信息技术有限公司
 * FileName: CollectTypeEnum
 * Author:   yi.li
 * Date:     2018/7/2 11:05
 * Description: 采集类型
 */
public enum PlatFormEnum {
    QIAOFANG("巧房","QIAOFANG"),
    BEE("小蜜书", "BEE");
    /**
     * 枚举值
     */
    private String value;
    /**
     * 描述
     */
    private String desc;

    PlatFormEnum(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }
    /**
     * 判断是否存在枚举value
     */
    public static boolean valueExist(String value) {
        return Arrays.stream(PlatFormEnum.values()).anyMatch(obj -> obj.getValue().equals(value));
    }

    /**
     * 判断是否存在枚举desc
     */
    public static boolean descExist(String desc) {
        return Arrays.stream(PlatFormEnum.values())
                .anyMatch(obj -> obj.getDesc().equals(desc));
    }

    /**
     * 匹配获取对应的Desc
     */
    public static String getExistDesc(String value) {
        return Arrays.stream(PlatFormEnum.values()).filter(obj -> obj.getValue().equals(value))
                .map(obj -> obj.getDesc()).findFirst().orElse(null);
    }


    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getValue() {
        return value;
    }


}
